#ifndef _GPRMC_H
#define _GPRMC_H
#include <stdio.h>
#include <libusb-1.0/libusb.h>
#include <time.h>
#include <sys/time.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>

typedef unsigned char u8;


struct package{
	u8 header;
	u8 kind;
	u8 length_07;
	u8 length_815;
	u8 length_1623;
	u8 length_2431;
	u8 *gprmc;
	u8 tail1;
	u8 tail2;
};

struct userDevice{
	/*Device descriptor*/
 
	/** USB-IF vendor ID */
	uint16_t idVendor;
 
	/** USB-IF product ID */
	uint16_t idProduct;
 
	/*Interface descriptor*/
 
	/** USB-IF class code for this interface. See \ref libusb_class_code. */
	uint8_t  bInterfaceClass;
 
	/** USB-IF subclass code for this interface, qualified by the
	 * bInterfaceClass value */
	uint8_t  bInterfaceSubClass;
 
	/*Endpoint descriptor*/
 
	
	
	uint8_t  bmAttributes;
 
	
	/*save parameter*/
 
	libusb_device *dev;
	libusb_device **devs;
 
 
	uint8_t bInEndpointAddress;
 
	
 
	/* Number of this interface */
	int  bInterfaceNumber;
};

int init_libusb(void);
int get_device_descriptor(struct libusb_device_descriptor *dev_desc,struct userDevice *user_device);
void substring(char *des,char *str,int n,int index);
void BCC(u8 *data,u8 *res);
int getClockTime();
void lenToHex(char *des,long len);
void getGPS(unsigned short USB_PRODUCT_ID,unsigned short USB_VENDOR_ID);
void *saveToPackage();

void main_gps(void);
extern int flag_exit_gps;

extern char str_gps_utc[32];

extern int flag_gps;


#endif
